package {
	import flash.geom.*;
	
	public class Weapon extends GameObject {
		static public var pool:ResourcePool = new ResourcePool(NewWeapon);
		protected var logic:Function = null;
		protected var collidedObject:GameObject = null;
		static public function NewWeapon():Weapon {
			return new Weapon();
		}
		
		public function Weapon() {
			super();
		}
		
		public function startupBasicWeapon(graphics:GraphicsResource, position:Point):void {
			super.startupGameObject(graphics, position, ZOrder.WeaponZOrder);		
			logic = basicWeaponLogic;
			this.collisionName = CollisionType.BISCUIT;
		}
		
		override public function shutdown():void {	
			super.shutdown();
			logic = null;	
		}
		
		override public function enterFrame(dt:Number):void {
			if (logic != null)
				logic(dt);
		}
		
		protected function basicWeaponLogic(dt:Number):void	{
			if (position.y < -graphics.bitmap.height)
				this.shutdown();
				if (collidedObject != null) {
					position = collidedObject.position.clone();
				}
		}
		
		override public function collision(other:GameObject):void {
			collidedObject=other;
			Player.score++
			ResourceManager.SplatFX.play();		
			other.shutdown();
			this.shutdown();
		}

	}
}
